home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1996 #6
/
Amiga Plus CD - 1996 - No. 06.iso
/
pd
/
tools
/
pc-heiniv0.56
/
source
/
popgroup.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-02
|
9KB
|
292 lines
/*
**
** popgroup.h Release 1
**
** Popgroup Class
** derived from MUIC_Group Class
** includes a panel with controlling functions
** for the Textwd Object (also opened).
** handles a Filerequester for opening Textfiles
** and a Stringreuester for searching Strings in
** the loaded text
**
** ©1996 Ctryxx/Trinomic (Stephan Quitzsch)
**
*/
#include <intuition/intuitionbase.h>
#define Popgroup_Base 0x3 // First digit
#define MUIM_Popgroup_Pop 0x301
#define MUIM_Popgroup_Unpop 0x302
#define MUIM_Popgroup_Toggle 0x303
#define MUIM_Popgroup_Gname 0x304
#define MUIM_Popgroup_Freq 0x305
#define SWIN_OK 901
#define SWIN_CANCEL 902
/*============================================================================*/
struct MUI_CustomClass *CL_Popgroup;
/*============================================================================*/
struct MUIP_Popgroup_Pop { ULONG MethodID; char *command; };
/*============================================================================*/
struct TagItem Reqtags[] =
{ ASL_Hail, (ULONG)"Select Text-file to load",
ASL_Window, NULL,
ASL_LeftEdge, 60,
ASL_TopEdge, 10,
ASL_Height, 250,
ASL_Width, 520,
TAG_DONE
};
/*============================================================================*/
/*= Popgroup class =*/
/*============================================================================*/
struct Popgroup_Data
{ BOOL popped; // Panel popped?
APTR mui_panel; // Objects
APTR mui_next;
APTR mui_back;
APTR mui_search;
APTR mui_sfwd;
APTR mui_sbwd;
APTR mui_path;
APTR mui_pathsel;
APTR mui_textview;
struct FileRequester *frequest; // File Requester
};
/*============================================================================*/
ULONG Popgroup_Freq( struct IClass *cl, Object *obj, Msg msg ) // get Filename from Requester
{
struct Popgroup_Data *data = INST_DATA( cl, obj );
char fname[256];
Reqtags[1].ti_Data = (ULONG) IntuitionBase->ActiveWindow; // I know, it`s a bit of a hack...
if ( MUI_AslRequest(data->frequest, Reqtags) )
{
strcpy( fname, data->frequest->rf_Dir );
AddPart( fname, data->frequest->rf_File, 255 );
DoMethod( data->mui_textview, MUIM_Textwd_Load, fname );
}
return 0l;
}
ULONG Popgroup_Gname( struct IClass *cl, Object *obj, Msg msg ) // get string to search for
{
struct Popgroup_Data *data = INST_DATA( cl, obj );
APTR mui_swin; // own string-requester
APTR mui_sstr;
APTR mui_ok;
APTR mui_can;
LONG app = xget( obj, MUIA_ApplicationObject );
DoMethod( data->mui_textview, MUIM_List_Select, MUIV_List_Select_All, MUIV_List_Select_Off, 0l );
mui_swin = WindowObject, // Requester-object
MUIA_Window_ID, 0x50434831,
MUIA_Window_Title, "Enter String to search",
MUIA_Window_RootObject, MUI_NewObject
( MUIC_Group,
MUIA_Group_Child, mui_sstr = MUI_NewObject
( MUIC_String,
MUIA_Frame, MUIV_Frame_String,
TAG_DONE
),
MUIA_Group_Child, MUI_NewObject
( MUIC_Group,
MUIA_Group_Horiz, TRUE,
MUIA_Group_Child, mui_ok = KeyButton( "Start", 's' ),
MUIA_Group_Child, mui_can = KeyButton( "Cancel", 'c' ),
TAG_DONE
),
TAG_DONE
),
End;
DoMethod( mui_swin, MUIM_Window_SetCycleChain, mui_sstr, mui_ok, mui_can, NULL );
if( mui_swin ) // If Object-creation succeded...
{
BOOL running = TRUE;
ULONG sigs;
// add it to Application Object
DoMethod( app, OM_ADDMEMBER, mui_swin );
DoMethod( mui_sstr, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, data->mui_textview, 2, MUIM_Textwd_Seek, MUIV_TriggerValue );
DoMethod( mui_sstr, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, app, 2, MUIM_Application_ReturnID, SWIN_CANCEL );
DoMethod( mui_ok, MUIM_Notify, MUIA_Pressed, FALSE, data->mui_textview, 2, MUIM_Textwd_Seek, xget(mui_sstr, MUIA_String_Contents) );
DoMethod( mui_ok, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, SWIN_CANCEL );
DoMethod( mui_swin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, SWIN_CANCEL );
DoMethod( mui_can, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, SWIN_CANCEL );
set( mui_swin, MUIA_Window_Open, TRUE );
set( (APTR)xget(obj, MUIA_WindowObject), MUIA_Window_Sleep, TRUE ); // accept no input from mainwindow!!!
while( running )
{
switch( DoMethod(app, MUIM_Application_Input, &sigs) )
{
case MUIV_Application_ReturnID_Quit:
shutdown( 0l );
break;
case SWIN_CANCEL:
running = FALSE;
break;
}
if( running && sigs ) Wait( sigs );
}
set( (APTR)xget(obj, MUIA_WindowObject), MUIA_Window_Sleep, FALSE ); // wake up mainwindow
set( mui_swin, MUIA_Window_Open, FALSE );
DoMethod( app, OM_REMMEMBER, mui_swin );
MUI_DisposeObject( mui_swin ); // kill Window Object
}
else ctryxxerror( "Can't open Search-window!" );
return 0l;
}
ULONG Popgroup_Pop( struct IClass *cl, Object *obj, struct MUIP_Popgroup_Pop *msg )
{ // pop panel
struct Popgroup_Data *data = INST_DATA( cl, obj );
switch( msg->command[0] )
{
case 'p': // pop
data->popped = TRUE;
set( data->mui_panel, MUIA_ShowMe, data->popped );
break;
case 'u': // unpop
data->popped = FALSE;
set( data->mui_panel, MUIA_ShowMe, data->popped );
break;
case 't': // toggle
data->popped = !data->popped;
set( data->mui_panel, MUIA_ShowMe, data->popped );
break;
}
return 0l;
}
ULONG Popgroup_New( struct IClass *cl, Object *obj, Msg msg )
{
APTR mui_panel;
APTR mui_next;
APTR mui_back;
APTR mui_search;
APTR mui_sfwd;
APTR mui_sbwd;
APTR mui_path;
APTR mui_pathsel;
APTR mui_textview;
struct Popgroup_Data *data;
obj = (Object*) DoSuperNew( cl, obj,
Child, mui_panel = VGroup,
MUIA_Frame, MUIV_Frame_Group,
Child, HGroup,
Child, mui_back = SimpleButton( "<" ),
Child, mui_next = SimpleButton( ">" ),
Child, mui_search = SimpleButton( "Search" ),
Child, mui_sfwd = SimpleButton( "Fwd" ),
Child, mui_sbwd = SimpleButton( "Bwd" ),
End,
Child, HGroup,
Child, mui_path = StringObject,
MUIA_Frame, MUIV_Frame_String,
End,
Child, mui_pathsel = ImageObject,
MUIA_Image_Spec, MUII_PopFile,
MUIA_Image_FreeVert, TRUE,
MUIA_Image_FreeHoriz, TRUE,
MUIA_FixWidth, 14,
MUIA_InputMode, MUIV_InputMode_RelVerify,
MUIA_Frame, MUIV_Frame_Button,
End,
End,
End,
Child, mui_textview = NewObject( CL_Textwd->mcc_Class, NULL, TAG_DONE ),
TAG_DONE
);
data = INST_DATA( cl, obj );
data->mui_panel = mui_panel;
data->mui_next = mui_next;
data->mui_back = mui_back;
data->mui_search = mui_search;
data->mui_sfwd = mui_sfwd;
data->mui_sbwd = mui_sbwd;
data->mui_path = mui_path;
data->mui_pathsel = mui_pathsel;
data->mui_textview = mui_textview;
if ( !(data->frequest = MUI_AllocAslRequest(ASL_FileRequest, NULL)) ) ctryxxerror( "Could not allocate Asl-Filerequester!" );
DoMethod( obj, MUIM_Popgroup_Pop, "p" );
DoMethod( data->mui_pathsel, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, MUIM_Popgroup_Freq );
DoMethod( data->mui_path, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, data->mui_textview, 2, MUIM_Textwd_Load, MUIV_TriggerValue );
DoMethod( data->mui_textview, MUIM_Notify, MUIA_Textwd_File, MUIV_EveryTime, data->mui_path, 3, MUIM_Set, MUIA_String_Contents, MUIV_TriggerValue );
DoMethod( data->mui_sfwd, MUIM_Notify, MUIA_Pressed, FALSE, data->mui_textview, 1, MUIM_Textwd_Nsk );
DoMethod( data->mui_sbwd, MUIM_Notify, MUIA_Pressed, FALSE, data->mui_textview, 1, MUIM_Textwd_Bsk );
DoMethod( data->mui_next, MUIM_Notify, MUIA_Pressed, FALSE, data->mui_textview, 1, MUIM_Textwd_Next );
DoMethod( data->mui_back, MUIM_Notify, MUIA_Pressed, FALSE, data->mui_textview, 1, MUIM_Textwd_Back );
DoMethod( data->mui_search, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, MUIM_Popgroup_Gname );
return (ULONG)obj;
}
ULONG Popgroup_Disp( struct IClass *cl, Object *obj, struct MUIP_Popgroup_Pop *msg )
{
struct Popgroup_Data *data = INST_DATA( cl, obj ); // Dispose PopgroupObject and Filerequester
if ( data->frequest ) MUI_FreeAslRequest( data->frequest );
return (ULONG)DoSuperMethodA( cl, obj, msg );
}
__saveds __asm ULONG Popgroup_Dispatcher( register __a0 struct IClass *cl, register __a2 Object *obj, register __a1 Msg msg )
{
struct Popgroup_Data *data = INST_DATA( cl, obj );
switch ( msg->MethodID )
{
case OM_NEW: return( Popgroup_New ( cl, obj, (APTR)msg ));
case OM_DISPOSE: return( Popgroup_Disp ( cl, obj, (APTR)msg ));
case MUIM_Popgroup_Pop: return( Popgroup_Pop ( cl, obj, (APTR)msg ));
case MUIM_Popgroup_Gname:return( Popgroup_Gname( cl, obj, (APTR)msg ));
case MUIM_Popgroup_Freq: return( Popgroup_Freq ( cl, obj, (APTR)msg ));
}
if( (msg->MethodID)>>8 == Textwd_Base ) // for Textwd-Class...
{ return (ULONG)DoSuperMethodA( CL_Textwd, data->mui_textview, msg );
}
return (ULONG)DoSuperMethodA( cl, obj, msg );
}